<!-- 用户列表 -->
 
 <table id='tab' class="easyui-datagrid" data-options="url:'{:U()}',fitColumns:true,singleSelect:true,toolbar:'#tool'">   
    <thead>   
        <tr>   
            <th data-options="field:'id',width:'100'">ID</th>               
            <th data-options="field:'username',width:'100'">用户名</th> 
            <th data-options="field:'gid',width:'100'">用户组</th>  
            <th data-options="field:'email',width:'100'">邮箱</th>  
            <th data-options="field:'ctime',width:'100'">添加时间</th>
            <th data-options="field:'utime',width:'100'">修改时间</th>   
            <th data-options="field:'lastlogin',width:'100'">登陆时间</th>     
            <th data-options="field:'ip',width:'100'">IP</th>   
        </tr>   
    </thead>   
    <tbody>   
        <tr>   
            <td>001</td><td>name1</td><td>2323</td>   
        </tr>   
        <tr>   
            <td>002</td><td>name2</td><td>4612</td>   
        </tr>   
    </tbody>   
</table>  
<div id='tool'>
<a href="{:U('add')}" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">添加</a>
<a id='editbtn' href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true">修改</a>
<a id='delbtn'  href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true">删除</a>
</div>
<script>
$('#editbtn').click(function(){
	
	var row=$('#tab').datagrid('getSelected');
	
	if(row){
		//alert(row.username);
		var url="{:U('edit','',false)}"+'/id/'+row.id;
		window.location.href=url;
	}else{
		alert('请先选中一行'); 
	}
	
	
	
});
//删除
$('#delbtn').click(function(){
	var row=$('#tab').datagrid('getSelected');
	if(row){
		
	$.ajax({
		url:"{:U('del')}",
		data:{id:row.id},
		type:'post',
		dataType:'json',
		success:function(msg){
			if(msg.code==1){
				$('#tab').datagrid('reload');
			}else{
				alert(msg.message);
			}
			
		}
		
	});
		 
	}else{
		alert('请选择一行');
	}
	
});
</script>

